package com.yb0os1.mapper;

import com.yb0os1.annotation.AutoFill;
import com.yb0os1.entity.Category;
import com.yb0os1.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {
    @Insert("INSERT INTO category values (#{id},#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void insert(Category category);

    List<Category> select(String name, Integer type);

    @AutoFill(value = OperationType.UPDATE)
    void update(Category category);

    @Delete("delete from category where id = #{id}")
    void delete(Long id);

    @Select("select name from category where id=#{id}")
    String getCategoryName(Long id);
}
